<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>确认支付</title>
    <link rel="stylesheet" type="text/css" href="/css_z/base.css"/>
    <link rel="stylesheet" type="text/css" href="/css_z/zhifu.css"/>
    <link rel="stylesheet" type="text/css" href="/css_z/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="/css_z/loaders.min.css"/>
    <link rel="stylesheet" type="text/css" href="/css_z/loading.css"/>
    <script src="/js_z/rem.js"></script>
    <script src="/js_z/jquery.min.js" type="text/javascript"></script>
	<script src="/js/common.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
	<script type="text/javascript">
		$(window).load(function(){
			$(".loading").addClass("loader-chanage")
			$(".loading").fadeOut(300)
		})

		$(function(){
            var params = getParams();
	    	//计算内容上下padding
            //获取当前登录用户的(session)信息
            var user = JSON.parse(sessionStorage.getItem("user"));
            var currentMoney ;
            var costMoney;
			reContPadding({main:"#main",header:"#header",footer:"#footer"});
			function reContPadding(o){
				var main = o.main || "#main",
					header = o.header || null,
					footer = o.footer || null;
				var cont_pt = $(header).outerHeight(true),
					cont_pb = $(footer).outerHeight(true);
				$(main).css({paddingTop:cont_pt,paddingBottom:cont_pb});
			}
            $.ajax({
                async: false,
                url:'/users/orderId',
                method:"get",
                    data:{orderId:params.id},
                success: function (data) {
                    console.log(data);
                    costMoney = data.cost;
                    var orderNumber = "您的订单号 :"+data.orderNumber;
                    $('#orderNumber').html(orderNumber)
                    $('#ordercontent').renderValues(data);
                }
            })
            $.get('/signs/'+user.id+'/grade',function (data) {
                $('#jifen').html(data.grade)
                currentMoney=data.grade;
            });

            $("#zhifu").click(function () {
                if(currentMoney-costMoney >= 0) {
                    $.ajax({
                        async: false,
                        url: '/users/changeOrderstatus',
                        method: "put",
                        data: {status: 1, orderId: params.id},
                        success: function (data) {
                            $(document).dialog({
                                type: 'notice',
                                infoText: '亲您支付成功了哟！',
                                autoClose: 3000,
                                position: 'center'  // center: 居中; bottom: 底部
                            });
                            window.location.href = '/mine/shop/index.html'

                        }
                    })
                }else {
                    $(document).dialog({
                        type: 'notice',
                        infoText: '你的积分不够，好好努力签到吧！',
                        autoClose: 2000,
                        position: 'center'  // center: 居中; bottom: 底部
                    });
                }
            })
		});
	</script>
</head>
<!--loading页开始-->
<div class="loading">
    <div class="loader">
        <div class="loader-inner pacman">
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
        </div>
    </div>
</div>
<!--loading页结束-->
<body>
<header class="mui-bar mui-bar-nav report-header box-s" id="header">
    <a href="javascript:history.go(-1)"><i class="iconfont icon-fanhui fl"></i></a>
    <p>确认支付</p>
</header>
<div id="main" class="mui-clearfix contaniner sorder">
    <div class="warning clearfloat box-s">
        提示：请在24小时内完成在线支付，逾期将视为订单无效
    </div>
    <div class="odernum clearfloat" id="ordercontent">
        <ul>
            <li id="orderNumber"></li>
            <li>应付积分：<span render-html="cost"></span></li>
            <li>我拥有的积分：<span id="jifen"></span></li>
        </ul>
    </div>


	    	<a href="#" class="address-add fl" id="zhifu">
	     		确认支付
	     	</a>
	    </div>
	    
	</body>
</html>
